<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>表单页面</title>
    <link rel="stylesheet" href="/static/component/pear/css/pear.css" />
    <style>
          .userp_1{
            position: relative;
        }
        .userp_2{
            position:absolute;
            right:20px;
            top:8px;
            font-weight: bold;
        }
        .layui-table-tool{
            padding-bottom: 0px!important;
        }
        .layui-table-tool-temp .layui-form{
            margin-top: 0px!important;
        }
        .layui-table-tool-temp .layui-form .layui-form-item{
            margin-bottom: 0px!important;
        }

        
    </style>
</head>

<body class="pear-container">
    
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="tableId" lay-filter="user-table"></table>
        </div>
    </div>
    <script type="text/html" id="user-toolbar">
        <form class="layui-form" action="" id="formSearchId">
            <div class="layui-form-item">
                <div class="layui-input-inline">
                    <input type="text" name="sn"  placeholder="单号" class="layui-input">
                </div>
                    <div class="layui-input-inline">
                        <select name="type">
                            <option value="0">全部</option>
                            <option value="1">余额提现</option>
                            <option value="2">套餐返佣</option>
                        </select>
                </div>
                <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="user-query">
                    <i class="layui-icon layui-icon-search"></i>
                    查询
                </button>
            </div>
        </form>
    </script>
    <script type="text/html" id="user-price">
        {{#if (d.price_type ) { }}
            <span style="color:blue">+{{ d.price }}</span>
        {{# }else{ }}
            <span style="color:red">-{{d.price}}</span>
        {{# } }}
    </script>
    <script type="text/html" id="user-type">
        {{#if (d.type ) { }}
            <span class="layui-badge layui-bg-black">套餐返佣</span>
        {{# }else{ }}
            <span class="layui-badge layui-bg-blue">余额提现</span>
        {{# } }}
    </script>
    <script type="text/html" id="user-usermsg">
        <img src="{{d.umsg.head_img}}" class="layui-nav-img">
        <span>{{d.umsg.nickname}}
        </span>
        {{#if (d.umsg.mobile ) { }}
            <span>| {{d.umsg.mobile}}</span>
        {{# } }}
    </script>

    <script type="text/html" id="user-yprice">
        <span>{{d.yprice}}</span>
    </script>



   
    <script src="/static/user/js/jquery.min.js"></script>
    <script src="/static/component/layui/layui.js"></script>
    <script src="/static/component/pear/pear.js"></script>
    <script>
        layui.use(['table', 'form', 'jquery','common'], function() {
				let table = layui.table;
				let form = layui.form;
				let $ = layui.jquery;
				let common = layui.common;
                let cols = [
                    [{
                        title: '明细单号',
                        field: 'sn',
                        align: 'left',
                        width: 120
                    },
                    {
                        title: '变动金额',
                        field: 'price',
                        align: 'center',
                        templet: '#user-price',
                        width:100
                    },
                    {
                        title: '变动类型',
                        field: 'type',
                        templet: '#user-type',
                        width: 120
                    },
                    {
                        title: '变动备注',
                        field: 'remark',
                    },
                    {
                            title: '关联用户',
                            field: 'nickname',
                            align: 'center',
                            templet: '#user-usermsg',
                            width: 120,
                        },
                    {
                        title: '变动时间',
                        field: 'addtime',
                        align: 'center',
                        
                    }
                    
                     
                    ]
                    
                ];
                table.render({
                    elem: '#tableId',
                    url: "{:url('user/balanceinfo')}?id={$Request.get.id}",
                    page: true,
                    cols: cols,
                    skin: 'line',
                    toolbar: '#user-toolbar',
                    defaultToolbar: [{
                        title: '刷新',
                        layEvent: 'refresh',
                        icon: 'layui-icon-refresh',
                    }]
                });
                table.on('toolbar(user-table)', function (obj) {
                    if (obj.event === 'refresh') {
					    window.refresh();
                    }
                });
                window.refresh = function(param) {
					table.reload('tableId');
				}
                
                
                form.on('submit(user-query)', function (data) {
                    _query_log=data.field;
                    table.reload('tableId', {
                        page: {curr: 1 },
                        where: data.field
                    })
                    $("#formSearchId").find("input[name='sn']").val(_query_log.sn); 
                    $("#formSearchId").find("select[name='type']").val(_query_log.type); 
                    return false;
                });

			})
            _query_log={
                    sn:'',
                    type:0
                };
    </script>
    {include file="base/unitjs"}
</body>

</html>